package com.hellpro.lolbox.mine.view;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hellpro.lolbox.R;
import com.hellpro.lolbox.base.LolBaseActivity;
import com.hellpro.lolbox.mine.presenter.PhoneSmsCodePresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PhoneSmsLoginActivity extends LolBaseActivity implements IPhoneLoginActivity {


    @BindView(R.id.main_phoneSms_iv_return)
    ImageView mainPhoneSmsIvReturn;
    @BindView(R.id.mine_phoneSms_et_smsCode)
    EditText minePhoneSmsEtSmsCode;
    @BindView(R.id.mine_phoneSMs_tv_smsCode)
    TextView minePhoneSMsTvSmsCode;
    @BindView(R.id.mine_phoneSms_btn_register)
    Button minePhoneSmsBtnRegister;
    @BindView(R.id.mine_phoneSms_et_phone)
    EditText minePhoneSmsEtPhone;
    private PhoneSmsCodePresenter presenter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_phone_sms_login;
    }

    @Override
    public void initView() {
        presenter = new PhoneSmsCodePresenter(this);
    }


    @OnClick({R.id.mine_phoneSMs_tv_smsCode, R.id.mine_phoneSms_btn_register,R.id.main_phoneSms_iv_return})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.mine_phoneSMs_tv_smsCode:
                presenter.setSmsCode();
                break;
            case R.id.mine_phoneSms_btn_register:
                presenter.setPhoneLogin();
                finish();
                break;
            case R.id.main_phoneSms_iv_return:
                finish();
                break;
        }
    }

    @Override
    public EditText getEtPhoneNo() {
        return minePhoneSmsEtPhone;
    }

    @Override
    public EditText getEtSmsCode() {
        return minePhoneSmsEtSmsCode;
    }

    @Override
    public TextView getTvCode() {
        return minePhoneSMsTvSmsCode;
    }

    @Override
    public Button getBtnLogin() {
        return minePhoneSmsBtnRegister;
    }

    @Override
    public Context getPhoneSmsContext() {
        return PhoneSmsLoginActivity.this;
    }

    @Override
    public SharedPreferences getSp() {
        return getSharedPreferences("isLogin", MODE_PRIVATE);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
